package routers

import (
    "github.com/kataras/iris/v12"
    "iris-server/src/controller"
)

type Routers struct {
    *controller.ExampleController
    *controller.DemoController
}

var router *Routers

// 1. 在初始化函数中引入所有Controller对象
func init() {
    router = &Routers{
        controller.NewExampleController(),
        controller.NewDemoController(),
    }
}

// -------------------------以上初始化时机加载--------------------------

// LoadRouterList 2. 加载路由器列表
func LoadRouterList(app *iris.Application) {
    // v1对象是由APIBuilder对象构建，具体代码在 \iris\v12@v12.1.8\core\router\api_builder.go
    v1 := app.Party("/v1")
    router.ExampleRouterList(v1)
    router.DemoRouterList(v1)
}
